package cn.forkway;

import cn.forkway.domain.Student;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * @program: java-learn-mybatis
 * @className: myAPP.java
 * @author: River Ray
 * @description: 测试SQL查询
 * @createTime 2021年10月09日 17:14:00
 */
public class myAPP {
   public static void main(String[] args) throws IOException {
      String config = "mybatis.xml";
      InputStream in = Resources.getResourceAsStream(config);
      SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
      SqlSessionFactory factory = builder.build(in);
      SqlSession  sqlSession = factory.openSession();
      String sqlId = "cn.forkway.domain.Student"+"."+"selectStudent";
      List<Student> studentList = sqlSession.selectList(sqlId);
      studentList.forEach(System.out::println);
      sqlSession.close();

   }
}
